import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: AnimateTextStylePage());
  }
}

class AnimateTextStylePage extends StatefulWidget {
  @override
  _AnimateTextStylePageState createState() => _AnimateTextStylePageState();
}

class _AnimateTextStylePageState extends State<AnimateTextStylePage> {
  bool isClick = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('动画示例')),
      body: SizedBox.expand(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            AnimatedDefaultTextStyle(
              style: isClick
                  ? TextStyle(
                      fontWeight: FontWeight.bold,
                      color: Colors.red,
                      fontSize: 16,
                    )
                  : TextStyle(
                      fontWeight: FontWeight.normal,
                      fontSize: 12,
                      color: Colors.black,
                    ),
              duration: Duration(seconds: 1),
              child: Text("早起的年轻人"),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            isClick = !isClick;
          });
        },
        child: Icon(Icons.change_circle),
      ),
    );
  }
}
